package com.cskaoyan.service.wx;

import com.cskaoyan.bean.vo.homeIndex.*;
import com.cskaoyan.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 杨杰
 * @version V1.0
 * @Package com.cskaoyan.service
 * @date 2020/12/8 14:18
 * @Copyright © 暂时还没有
 * @description
 */
@Service
public class HomePageServiceImp implements HomePageService{

    @Autowired
    IndexMapper indexMapper;

    @Override
    public HomeIndexInfo homeIndexMessage() {

        HomeIndexInfo indexInfo = new HomeIndexInfo();
        //1.新产品，价格最高的6个
        List<NewGoods> newGoodsList = indexMapper.queryNewGoods();
        //NewGoods[] newGoodsList = indexMapper.queryNewGoods();
        indexInfo.setNewGoodsList(newGoodsList);

        //2.优惠券，前六
        List<CouponIndex> couponList = indexMapper.queryCoupons();
        indexInfo.setCouponList(couponList);

        //3.种类
        List<ChannelIndex> channel = indexMapper.queryChannels();
        indexInfo.setChannel(channel);

        //4.团购
        List<GrouponIndex> grouponList = indexMapper.queryGroupon();
        indexInfo.setGrouponList(grouponList);

        //5.banner
        List<BannerIndex>  banner = indexMapper.queryBanner();
        indexInfo.setBanner(banner);

        //6.brand
        List<BrandIndex> brandList = indexMapper.queryBrand();
        indexInfo.setBrandList(brandList);

        //7.hotGoods
        List<HotGoodsIndex> hotGoodsList = indexMapper.queryHotGoods();
        indexInfo.setHotGoodsList(hotGoodsList);

        //8.topic
        List<TopicIndex> topicList = indexMapper.queryTopic();
        indexInfo.setTopicList(topicList);

        //9.floorGoodsList
        FloorGoodsIndex floorGood = new FloorGoodsIndex();
        List<FloorGoodsIndex> floorGoodsList = new ArrayList<>();
        String[] a = new String[]{"锅具","被枕","床品件套","布艺软装"};
        for (int i = 0; i < a.length; i++) {
            floorGood.setName(a[i]);

            floorGood.setId(indexMapper.queryFloorId(a[i]));

            floorGood.setGoodsList(indexMapper.queryGoodsOfFloor(a[i]));//4条goods记录
            System.out.println("goods:   "+floorGood.getGoodsList());
            floorGoodsList.add(floorGood);
            floorGood = new FloorGoodsIndex();
        }
        indexInfo.setFloorGoodsList(floorGoodsList);
        return indexInfo;
    }
}
